<template>
    <div class="pageWrapper">
        <Row>
            <Col :xs="24" :sm="24" :md="24" :lg="24">
                <Table
                    class="pageTable"
                    border
                    :columns="columns11"
                    :data="tableData"
                    style="width: 1000px"
                ></Table>
            </Col>
        </Row>

        <Form class="formWrap" ref="formRef" :model="formData" inline>
            <div class="formItem">
                <h3>平台流水-其他信息</h3>
                <FormItem label="支付订单号：" style="width:32%">
                    <div>{{ formData.paymentId }}</div>
                </FormItem>
                <FormItem label="渠道支付订单号：" style="width:32%">
                    <div>{{ formData.flowId }}</div>
                </FormItem>
                <FormItem label="支付渠道：" style="width:32%">
                    <div>{{ formData.payChannelCn }}</div>
                </FormItem>
                <FormItem label="交易方式：" style="width:32%">
                    <div>{{ formData.payWayCn }}</div>
                </FormItem>
                <FormItem label="交易类型：" style="width:32%">
                    <div>{{ formData.transactionTypeCn }}</div>
                </FormItem>
                <FormItem label="优惠金额：" style="width:32%">
                    <div>{{ formData.discount | moneyNUm }}</div>
                </FormItem>
                <FormItem label="子订单数量：" style="width:32%">
                    <div>{{ formData.orderNum }}</div>
                </FormItem>
                <FormItem label="创建时间：" style="width:32%">
                    <div>{{ formData.createTime }}</div>
                </FormItem>
                <FormItem label="交易时间：" style="width:32%">
                    <div>{{ formData.payTime }}</div>
                </FormItem>
                <FormItem label="付款人信息：" style="width:32%">
                    <div>{{ formData.openid }}</div>
                </FormItem>
                <FormItem label="付款ID：" style="width:32%">
                    <div>{{ formData.uid }}</div>
                </FormItem>
            </div>
        </Form>

        <Form class="formWrap" ref="formRef" :model="formBankData" inline>
            <div class="formItem">
                <h3>银行流水-其他信息</h3>
                <FormItem label="商户订单号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="银行流水号：" style="width:32%">
                    <div>{{ formBankData.payChannelOrderid }}</div>
                </FormItem>
                <FormItem label="第三方订单号：" style="width:32%">
                    <div>{{ formBankData.originalFlowId }}</div>
                </FormItem>
                <FormItem label="支付方式：" style="width:32%">
                    <div>{{ formBankData.payWayCn }}</div>
                </FormItem>
                <FormItem label="交易类型：" style="width:32%">
                    <div>{{ formBankData.transactionTypeCn }}</div>
                </FormItem>
                <FormItem label="交易币种：" style="width:32%">
                    <div>{{ formBankData.transactionCurrency }}</div>
                </FormItem>
                <FormItem label="交易日期：" style="width:32%">
                    <div>{{ formBankData.payTime }}</div>
                </FormItem>
                <FormItem label="交易时间：" style="width:32%">
                    <div>{{ formBankData.payTime }}</div>
                </FormItem>
                <FormItem label="付款人信息：" style="width:32%">
                    <div>{{ formBankData.payerInformation }}</div>
                </FormItem>
                <FormItem label="付款银行：" style="width:32%">
                    <div>{{ formBankData.payingBank }}</div>
                </FormItem>
                <FormItem label="交易金额：" style="width:32%">
                    <div>{{ Math.abs(formBankData.payAmount) | moneyNUm }}</div>
                </FormItem>
                <FormItem label="手续费：" style="width:32%">
                    <div>{{ formBankData.serviceCharge | moneyNUm }}</div>
                </FormItem>
                <FormItem label="结算金额：" style="width:32%">
                    <div>{{ formBankData.settlementAmount | moneyNUm }}</div>
                </FormItem>
                <FormItem label="费率：" style="width:32%">
                    <div>{{ (formBankData.rate || 0) + '%' }}</div>
                </FormItem>
                <FormItem label="订单原始金额：" style="width:32%">
                    <div>{{ formBankData.originalOrderAmount | moneyNUm }}</div>
                </FormItem>
                <FormItem label="免充值优惠劵金额：" style="width:32%">
                    <div>{{ formBankData.freeRechargeCouponAmount | moneyNUm }}</div>
                </FormItem>
                <FormItem label="企业红包金额：" style="width:32%">
                    <div>{{ formBankData.businessRedEnvelope | moneyNUm }}</div>
                </FormItem>
                <FormItem label="企业红包退款金额：" style="width:32%">
                    <div>{{ formBankData.refundBusinessRedEnvelope | moneyNUm }}</div>
                </FormItem>
                <FormItem label="平台优惠金额：" style="width:32%">
                    <div>{{ formBankData.platformPreferentialAmount | moneyNUm }}</div>
                </FormItem>
                <FormItem label="账单日期：" style="width:32%">
                    <div>{{ formBankData.statementDate }}</div>
                </FormItem>
                <FormItem label="完成日期：" style="width:32%">
                    <div>{{ formBankData.completionDate }}</div>
                </FormItem>
                <FormItem label="清分日期：" style="width:32%">
                    <div>{{ formBankData.clearingDate }}</div>
                </FormItem>
                <FormItem label="清分账号：" style="width:32%">
                    <div>{{ formBankData.clearingAccount }}</div>
                </FormItem>
                <FormItem label="清分结果：" style="width:32%">
                    <div>{{ formBankData.clearingResult }}</div>
                </FormItem>

                <FormItem label="商品名称：" style="width:32%">
                    <div>{{ formBankData.goodsName }}</div>
                </FormItem>
                <FormItem label="门店名称：" style="width:32%">
                    <div>{{ formBankData.storeName }}</div>
                </FormItem>
                <FormItem label="门店编号：" style="width:32%">
                    <div>{{ formBankData.storeNo }}</div>
                </FormItem>
                <FormItem label="收银员：" style="width:32%">
                    <div>{{ formBankData.cashier }}</div>
                </FormItem>
                <FormItem label="原交易商户订单号：" style="width:32%">
                    <div>{{ formBankData.originalMerOrderId }}</div>
                </FormItem>
                <FormItem label="原交易银行流水号：" style="width:32%">
                    <div>{{ formBankData.originalFlowId }}</div>
                </FormItem>
                <FormItem label="原交易第三方的订单号：" style="width:32%">
                    <div>{{ formBankData.originalPayChannelOrderid }}</div>
                </FormItem>
                <FormItem label="业务种类：" style="width:32%">
                    <div>{{ formBankData.businesType }}</div>
                </FormItem>
                <!-- <FormItem label="商户保留域：" style="width:32%">
                    <div>{{ formBankData.merchant_reservation_domain }}</div>
                </FormItem> -->
                <FormItem label="收款方备注：" style="width:32%">
                    <div>{{ formBankData.payeeRemarks }}</div>
                </FormItem>
                <FormItem label="付款方备注：" style="width:32%">
                    <div>{{ formBankData.payerRemarks }}</div>
                </FormItem>
                <FormItem label="退款备注：" style="width:32%">
                    <div>{{ formBankData.refundRemarks }}</div>
                </FormItem>

                <!-- <FormItem label="商户名称：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="商户号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="第三方商户号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="门店名称：" style="width:32%">
                    <div>{{ formBankData.storeName }}</div>
                </FormItem>
                <FormItem label="门店编号：" style="width:32%">
                    <div>{{ formBankData.storeNo }}</div>
                </FormItem>
                <FormItem label="商户订单号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="交易完成时间：" style="width:32%">
                    <div>{{ formBankData.payTime }}</div>
                </FormItem>
                <FormItem label="第三方订单号：" style="width:32%">
                    <div>{{ formBankData.originalMerchantOrderNo }}</div>
                </FormItem>
                <FormItem label="商品名称：" style="width:32%">
                    <div>{{ formBankData.goodsName }}</div>
                </FormItem>

                <FormItem label="结算金额：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>

                <FormItem label="支付方式：" style="width:32%">
                    <div>{{ formBankData.payWayCn }}</div>
                </FormItem>
                <FormItem label="交易币种：" style="width:32%">
                    <div>{{ formBankData.transactionCurrency }}</div>
                </FormItem>
                <FormItem label="交易类型：" style="width:32%">
                    <div>{{ formBankData.transactionTypeCn }}</div>
                </FormItem>

                <FormItem label="优惠金额：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>

                <FormItem label="付款银行：" style="width:32%">
                    <div>{{ formBankData.payingBank }}</div>
                </FormItem>
                <FormItem label="清分账号：" style="width:32%">
                    <div>{{ formBankData.clearingAccount }}</div>
                </FormItem>

                <FormItem label="交易状态：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>

                <FormItem label="清分日期：" style="width:32%">
                    <div>{{ formBankData.clearingDate }}</div>
                </FormItem>
                <FormItem label="退款金额：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="清分结果：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="元交易流水号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="设备号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="收银员：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="终端机型：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="收款方备注：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="付款方备注：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem> -->


                <!-- <FormItem label="商户订单号：" style="width:32%">
                    <div>{{ formBankData.merOrderNo }}</div>
                </FormItem>
                <FormItem label="银行流水号：" style="width:32%">
                    <div>{{ formBankData.payChannelOrderid }}</div>
                </FormItem>
                <FormItem label="交易币种：" style="width:32%">
                    <div>{{ formBankData.transactionCurrency }}</div>
                </FormItem>
                <FormItem label="免充值优惠劵金额：" style="width:32%">
                    <div>{{ formBankData.freeRechargeCouponAmount ? `${formBankData.freeRechargeCouponAmount / 100}元` : '' }}</div>
                </FormItem>
                <FormItem label="企业红包金额：" style="width:32%">
                    <div>{{ formBankData.businessRedEnvelope ? `${formBankData.businessRedEnvelope / 100 }元` : '' }}</div>
                </FormItem>
                <FormItem label="企业红包退款金额：" style="width:32%">
                    <div>{{ formBankData.refundBusinessRedEnvelope ? `${formBankData.refundBusinessRedEnvelope / 100}元` : '' }}</div>
                </FormItem>
                <FormItem label="清分日期：" style="width:32%">
                    <div>{{ formBankData.clearingDate }}</div>
                </FormItem>
                <FormItem label="清分账号：" style="width:32%">
                    <div>{{ formBankData.clearingAccount }}</div>
                </FormItem>
                <FormItem label="清分结果：" style="width:32%">
                    <div>{{ formBankData.clearingResult }}</div>
                </FormItem>
                <FormItem label="收银员：" style="width:32%">
                    <div>{{ formBankData.cashier }}</div>
                </FormItem>
                <FormItem label="原交易商户订单号：" style="width:32%">
                    <div>{{ formBankData.originalMerchantOrderNo }}</div>
                </FormItem>
                <FormItem label="原交易银行流水号：" style="width:32%">
                    <div>{{ formBankData.original_bank_serial_number }}</div>
                </FormItem>
                <FormItem label="收款方备注：" style="width:32%">
                    <div>{{ formBankData.payeeRemarks }}</div>
                </FormItem>
                <FormItem label="付款方备注：" style="width:32%">
                    <div>{{ formBankData.payerRemarks }}</div>
                </FormItem>
                <FormItem label="退款备注：" style="width:32%">
                    <div>{{ formBankData.refundRemarks }}</div>
                </FormItem> -->
                <!-- <FormItem label="商户保留域：" style="width:32%">
                    <div>{{ formBankData.merchant_reservation_domain }}</div>
                </FormItem> -->
                <!-- <FormItem label="商品名称：" style="width:32%">
                    <div>{{ formBankData.goodsName }}</div>
                </FormItem>
                <FormItem label="业务种类：" style="width:32%">
                    <div>{{ formBankData.businesType }}</div>
                </FormItem> -->
            </div>
        </Form>

        <div class="childerOlder">
            <h4 class="title">请对子订单进行标记</h4>
            <Table border :columns="columns" :data="dataList" class="table">

                <template slot-scope="{ row, index }" slot="diffCause">
                    <Select v-model="dataList[index].errorReason" placeholder="请选择" :transfer="true" @on-change="changeErrorReason">
                        <Option :value="item.key" v-for="(item, key) in differenceList" :key="key">{{item.value}}</Option>
                    </Select>
                </template>

                <template slot-scope="{ row, index }" slot="remarkRow">
                    <Input type="text" v-model="dataList[index].errorRemark" :disabled="(dataList[index].errorReason && dataList[index].errorReason == 'custom') ? false : true" maxlength="32" placeholder="请输入，字数不超过32" />
                </template>

                <template slot-scope="{ row, index }" slot="monery">
                    <Input type="text" v-model="dataList[index].errorAmount" :disabled="(dataList[index].errorReason && dataList[index].errorReason != 'normal') ? false : true" maxlength="32" placeholder="请输入金额">
                        <span slot="append">元</span>
                    </Input>
                </template>

            </Table>
            <span class="explain">差异金额说明：由于差异金额是平台侧减银行侧，所以此处填写差异金额时，需要填写总差异金额在各子订单上的对应金额。</span>
            <div class="btn">
                <Button type="primary" :disabled="disabledSubmit" @click="handleSubmit">提交</Button>
                <Button type="primary"  style="margin-left: 8px" @click="back" >返回</Button>
            </div>
        </div>

        <!-- <AbnormalCause
            :differenceList="differenceList"
            @submit="submitFun"
        ></AbnormalCause> -->
    </div>
</template>
<script>
import { Modal, Message, Col, Row, Form, Input, FormItem, Table, Select, Option, Button } from "view-design";
import { namespace } from "../Module/settlementAbnormalModule";
import RemoteTable from "@/components/RemoteTable";
import SearchBar from "@/components/SearchBar";
import AbnormalCause from "@/components/AbnormalCause";
import Authc from "@/components/Authc";
import config from "@/utils/config";
import util from '@/utils/util';
import appService from "@/utils/appService";

export default {
    name: "settlementAbnormalAloneProcessing",
    components: {
        RemoteTable,
        AbnormalCause,
        Authc,
        Modal,
        Message,
        Col,
        Row,
        Form,
        Input,
        FormItem,
        Table,
        Select,
        Option,
        Button
    },
    data() {
        return {
            namespace: namespace,
            disabledSubmit: false,
            tableData: [
                // {
                //     key: "渠道支付订单号",
                //     value: "",
                //     bankKey: "第三方订单号",
                //     bankValue: ""
                // },
                // {
                //     key: "交易方式",
                //     value: "",
                //     bankKey: "支付方式",
                //     bankValue: ""
                // },
                // {
                //     key: "交易类型",
                //     value: "",
                //     bankKey: "交易类型",
                //     bankValue: ""
                // },
                // {
                //     key: "通道费率",
                //     value: "",
                //     bankKey: "费率",
                //     bankValue: ""
                // },
                // {
                //     key: "交易金额(元)",
                //     value: "",
                //     bankKey: "交易金额(元)",
                //     bankValue: ""
                // },
                // {
                //     key: "优惠金额(元)",
                //     value: "",
                //     bankKey: "平台优惠金额(元)",
                //     bankValue: ""
                // },
                // {
                //     key: "结算金额(元)",
                //     value: "",
                //     bankKey: "结算金额(元)",
                //     bankValue: ""
                // },
                // {
                //     key: "订单交易时间",
                //     value: "",
                //     bankKey: "交易时间",
                //     bankValue: ""
                // },
                // {
                //     key: "付款人信息",
                //     value: "",
                //     bankKey: "付款人信息",
                //     bankValue: ""
                // },
                // {
                //     key: "商户名称",
                //     value: "",
                //     bankKey: "门店名称",
                //     bankValue: ""
                // },
                // {
                //     key: "商户编码",
                //     value: "",
                //     bankKey: "门店编码",
                //     bankValue: ""
                // },
                // {
                //     key: "原交易渠道支付订单号",
                //     value: "",
                //     bankKey: "原交易第三方订单号",
                //     bankValue: ""
                // }
                {
                    key: "收单机构订单号",
                    value: "",
                    bankKey: "银行流水号",
                    bankValue: ""
                },
                {
                    key: "订单金额",
                    value: "",
                    bankKey: "交易金额",
                    bankValue: ""
                },
                {
                    key: "通道费率",
                    value: "",
                    bankKey: "费率",
                    bankValue: ""
                },
                {
                    key: "手续费",
                    value: "",
                    bankKey: "手续费",
                    bankValue: ""
                },
                {
                    key: "优惠金额",
                    value: "",
                    bankKey: "平台优惠金额",
                    bankValue: ""
                }
            ],
            diffData: '', /** 差异原因 */
            remarkData: '', /** 备注 */
            moneryData: '', /** 差异金额 */
            dataList: [], /** 子订单列表数据 **/
            columns: [
                {
                    title: "子订单号",
                    key: "subOrderId",
                    minWidth: 80,
                    align: "center"
                },
                {
                    title: "商户名称",
                    key: "merchantName",
                    minWidth: 80,
                    align: "center"
                },
                {
                    title: "商品名称",
                    key: "productName",
                    minWidth: 80,
                    align: "center"
                },
                {
                    title: "实付金额(元)",
                    key: "amount",
                    minWidth: 80,
                    align: "center",
                    render: (h, params) => {
                        let item = params.row.amount / 100;
                        return h('span', util.toMoney(item));
                    },
                },
                {
                    title: "差异原因",
                    slot: "diffCause",
                    key: "errorReason",
                    minWidth: 80,
                    align: "center"
                },
                {
                    title: "备注",
                    slot: 'remarkRow',
                    key: "errorRemark",
                    minWidth: 80,
                    align: "center"
                },
                {
                    title: "差异金额",
                    slot: 'monery',
                    key: "errorAmount",
                    minWidth: 80,
                    align: "center"
                },
                // {
                //     title: "操作",
                //     key: "action",
                //     slot: "action",
                //     width: 100,
                //     align: "center",
                //     permissions: ["trade:settlement:cmb"],
                //     width: 200
                // }
            ], /** 子订单标记 */
            formData: {},
            differenceList: [] /** 差异原因 **/,
            remark: "" /** 备注提交处理时候需要用到 **/,
            version: "" /** 版本号提交处理时候需要用到 **/,
            formBankData: {}, /** 银行账单-其他信息 */
            flowId: '', /** 支付流水号 */
            paymentTableItem: 0,
            bankTableItem: 0,
            columns11: [
                {
                    title: "平台流水",
                    align: "center",
                    children: [
                        {
                            title: "字段",
                            key: "key",
                            align: "center",
                            maxWidth: 150
                        },
                        {
                            title: "内容",
                            key: "value",
                            align: "center",
                            // minWidth: 253,
                            render(h, data) {
                                return h(
                                    "span",
                                    {
                                        class: {
                                            textRed:
                                                data.row.value !=
                                                data.row.bankValue
                                        }
                                    },
                                    data.row.value
                                );
                            }
                        }
                    ]
                },
                {
                    title: "银行流水",
                    align: "center",
                    children: [
                        {
                            title: "字段",
                            key: "bankKey",
                            align: "center",
                            maxWidth: 150
                        },
                        {
                            title: "内容",
                            key: "bankValue",
                            align: "center",
                            // minWidth: 253,
                            render(h, data) {
                                return h(
                                    "span",
                                    {
                                        class: {
                                            textRed:
                                                data.row.value !=
                                                data.row.bankValue
                                        }
                                    },
                                    data.row.bankValue
                                );
                            }
                        }
                    ]
                }
            ]
        };
    },
    created() {
        this.getDetail(this.$route.query.id);
        this.getDiffCauseList();
    },
    methods: {
        /** 获取详情 **/
        async getDetail(id) {
            try {
                let res = await this.$store.dispatch(
                    `${namespace}/getDetail`,
                    id
                );
                if (res.ret == 0) {
                    let paymentTableData = res.data.paymentOrderRes;
                    let bankTableData = res.data.bankRes;
                    this.flowId = paymentTableData.flowId; /** 支付流水号 */

                    /** 渠道支付订单号 / 银行流水号 **/
                    this.tableData[0].value = paymentTableData.payChannelOrderid;
                    this.tableData[0].bankValue = bankTableData.payChannelOrderid;

                    /** 交易方式 / 交易方式 **/
                    // this.tableData[1].value = paymentTableData.payWayCn;
                    // this.tableData[1].bankValue = bankTableData.payWayCn;

                    /** 交易类型 / 交易类型 **/
                    // this.tableData[2].value = paymentTableData.transactionTypeCn;
                    // this.tableData[2].bankValue = bankTableData.transactionTypeCn;

                    /** 订单金额 / 交易金额 **/
                    this.tableData[1].value = Math.abs(paymentTableData.orderAmount / 100);
                    this.paymentTableItem = Math.abs(paymentTableData.orderAmount / 100);
                    this.tableData[1].bankValue = Math.abs(bankTableData.payAmount / 100);
                    this.bankTableItem = Math.abs(bankTableData.payAmount / 100);

                    /** 通道费率 / 费率 **/
                    this.tableData[2].value = paymentTableData.rate ? `${paymentTableData.rate}%` : '0';
                    this.tableData[2].bankValue = bankTableData.rate ? `${bankTableData.rate}%` : '0';

                    /** 手续费 */
                    this.tableData[3].value = paymentTableData.serviceCharge / 100;
                    this.tableData[3].bankValue = bankTableData.serviceCharge / 100;

                    /** 优惠金额 / 平台优惠金额 **/
                    this.tableData[4].value = paymentTableData.discount / 100;
                    this.tableData[4].bankValue = Math.abs(bankTableData.platformPreferentialAmount / 100);

                    /** 结算金额 / 结算金额 **/
                    // this.tableData[6].value = paymentTableData.settlementAmount / 100;
                    // this.tableData[6].bankValue = bankTableData.settlementAmount / 100;

                    /** 订单交易时间 / 交易时间 **/
                    // this.tableData[7].value = paymentTableData.payTime;
                    // this.tableData[7].bankValue = bankTableData.payTime;

                    /** 付款人信息 / 付款人信息 **/
                    // this.tableData[8].value = paymentTableData.payerInformation;
                    // this.tableData[8].bankValue = bankTableData.payerInformation;

                    /** 商户名称 / 门店名称 **/
                    // this.tableData[9].value = paymentTableData.merchantName;
                    // this.tableData[9].bankValue = bankTableData.merchantName;

                    /** 商户编码 / 商户编码 **/
                    // this.tableData[10].value = paymentTableData.merchantCode;
                    // this.tableData[10].bankValue = bankTableData.merchantCode;

                    /** 原交易渠道支付订单号 / 交易第三方订单号 **/
                    // this.tableData[11].value = paymentTableData.originalFlowId;
                    // this.tableData[11].bankValue = bankTableData.originalFlowId;

                    /** 存放备注和版本号用于提交处理 **/
                    this.remark = res.data.remark;
                    this.version = res.data.version;

                    this.formData = res.data.paymentOrderRes || {}; /** 平台账单-其他信息 */
                    this.formBankData = res.data.bankRes || {}; /** 银行账单-其他信息 */

                    this.getDiffCauseChilderOlder(); /** 子订单标记 */
                }
            } catch (error) {
                this.$Message.error({
                    content: error
                });
            }
        },

        /** 获取子订单标记列表 */
        async getDiffCauseChilderOlder () {
            try {
                let params = {
                    flowId: this.flowId
                }
                let res = await this.$store.dispatch(`${namespace}/getDiffCauseChilderOlder`, params);
                if (res.data.ret === 0) {
                    this.dataList = res.data.data;
                    if (this.dataList && this.dataList.length > 0) {
                        this.disabledSubmit = false;
                    } else {
                        this.disabledSubmit = true;
                    }
                }
            } catch (error) {
                this.$Message.error({
                    content: error
                })
            }
        },

        /** 获取差异原因 **/
        async getDiffCauseList() {
            try {
                let obj = {
                    module: "payment_diff_config"
                };
                let res = await this.$store.dispatch(`${namespace}/getDiffCauseList`, obj);
                this.differenceList = res.data.data.map(e => {
                    return {
                        key: e.code,
                        value: e.name
                    };
                });
                this.differenceList.push(
                    {
                        key: 'normal',
                        value: '正常'
                    },
                    {
                    key: "custom",
                    value: "自定义"
                });
            } catch (error) {
                this.$Message.error({
                    content: error
                });
            }
        },

        /** 差异原因-选项后重置备注与差异金额 */
        changeErrorReason () {
            for (let i = 0; i < this.dataList.length; i++) {
                if (this.dataList.length < 2) {

                    this.$set(this.dataList[i], 'errorAmount', (this.paymentTableItem - this.bankTableItem))
                }
                if (this.dataList[i].errorReason == 'normal') {
                    this.$set(this.dataList[i], 'errorRemark', '');
                    this.$set(this.dataList[i], 'errorAmount', '');
                } else if (this.dataList[i].errorReason != 'normal' && this.dataList[i].errorReason != 'custom') {
                    this.$set(this.dataList[i], 'errorRemark', '');
                }
            }
        },

        /** 提交处理 **/
        handleSubmit() {
            for (let i = 0; i < (this.dataList && this.dataList.length); i++) {
                if (!this.dataList[i].errorReason) {
                    this.$Message.warning({
                        content: '请选择差异原因'
                    })
                    return;
                }
                if (this.dataList[i].errorReason == 'custom' && (!this.dataList[i].errorRemark || !this.dataList[i].errorAmount)) {
                    this.$Message.warning({
                        content: '请填写备注与差异金额'
                    })
                    return;
                }
                if (this.dataList[i].errorReason != 'custom' && this.dataList[i].errorReason != 'normal' && !this.dataList[i].errorAmount) {
                     this.$Message.warning({
                        content: '请填写差异金额'
                    })
                    return;
                }
            }
            Modal.confirm({
                render: (h, params) => {
                    return h("div", [
                        h(
                            "div",
                            {},
                            "提交后不可更改差异原因和备注，是否确认提交?"
                        )
                    ]);
                },
                onOk: async () => {
                    await this.$store.dispatch(`${namespace}/difftHandle`, this.dataList);
                    this.$Message.success({
                        content: "处理成功！"
                    });
                    setTimeout(() => {
                        this.$router.back(-1);
                    }, 1000);
                }
            });
        },
        back () {
            this.$router.back(-1);
        }
    },
    filters: {
        moneyNUm (num) {
            if (num == 0 || !num) {
                return '0.00';
            } else {
                console.log(num, '44')
                num = parseFloat(num / 100);
                num = num.toFixed(2);
                num = num.toLocaleString();
                if (num.indexOf('.') < 0) {
                num = num + '.00';
                }
                return num;
                // let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
                // return reg.test(val)
            }
        }
    }
};
</script>
<style scoped>
.title {
    display: inline-block;
    font-size: 14px;
}
.title span {
    font-size: 18px;
    color: #3399ff;
}
.formWrap {
    margin-top: 20px;
}
.formWrap h3 {
    font-size: 14px;
}
.formWrap .ivu-form-item {
    margin-bottom: 0px;
}
.formItem {
    margin-bottom: 20px;
}
.pageWrapper .pageTable >>> .ivu-table-header .ivu-table-column-center {
    color: #fff;
    background-color: #69f;
}
.pageWrapper .pageTable >>> .ivu-table-row .ivu-table-column-center:nth-child(odd) {
    background-color: #d7d7d7;
}
.pageWrapper .pageTable >>> .textRed {
    color: red;
}
</style>
<style lang="less" scoped>
.childerOlder {
    .title {
        margin-bottom: 10px;
    }
    .table {
        margin-bottom: 8px;
    }
    .explain {
        margin: 16px 0;
        display: inline;
        padding: 6px 0;
        background-color: #9efdbc;
    }
    .btn {
        margin: 20px 0;
    }
    // .titleSpan {
        /deep/.ivu-table-cell {
            overflow: auto;
            // height: 35px;
        }
    // }
}

</style>
